package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.service.SetmealService;
import freemarker.template.Configuration;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("userSetmealController")
@RequestMapping("/setmeal")
@Slf4j
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    /**
     * 用户端-套餐列表数据
     */
    @PostMapping("/getSetmeal")
    public Result getSetmeal(){
        return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS, setmealService.getSetmeal()) ;
    }

    /**
     * 根据套餐id查询套餐详情
     * @return
     */
    @PostMapping("/findById")
    public Result findById(Integer id){
        log.info("根据套餐id查询套餐详情:{}", id);
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS, setmealService.findById(id));
    }

}